<template>
	<div>
		<el-tree ref="wytree"
		:data="rosources"
		node-key="id"
		show-checkbox
		default-expand-all
		:props="props"
		:default-checked-keys="values"></el-tree>
		<el-button size="small" type="success" style="margin-left: 20px;" plain @click="save">保存</el-button>
	</div>
</template>

<script>
	import {
		get,
		post
	} from '@/plugins/axios'
	export default {
		name: 'resourceList',
		created() {
			this.roleId = this.$route.query.roleId;
			this.getData();

		},
		data() {
			const module = '/ums-resource'
			return {
				url: {
					list: module + '/list',
				},
				query: {
					name: '',
					pageNo: 1,
					pageSize: 8
				},
				rosources:[],
				defaultProps: {
				          children: 'children',
				          label: 'label'
				        },
				props: {
					label: 'name',
					children: 'zones'
				}
			}
		},
		methods: {
			getData() {
				get(this.url.list, this.query, response => {
					console.log(response.records)
					const res = response.records;
					const resources = {
						
					}
					
				})
			},
			save() {
				post('/ums-role-user/save', {
					roleId: this.roleId,
					userIds: this.values
				}, response => {
					console.log("111111")
				})
			},
			loadNode(node, resolve) {
				
			},
			handleCheckChange(data, checked, indeterminate) {
				console.log(data, checked, indeterminate);
			},
		},
	}
</script>

<style>
</style>
